#include <cstdio>

int su[ 200000 ], sucnt;

void init( )
{
    bool visit[ 2000001 ];
    int i, j;
    for ( i = 0; i <= 2000000; i++ )
        visit[ i ] = false;
    for ( i = 2; i <= 2000000; i++ )
        if ( !visit[ i ] )
        {
            su[ sucnt++ ] = i;
            for ( j = i * 2; j <= 2000000; j += i )
                visit[ j ] = true;
        }
}

__int64 C( int n, int m )
{
    int f[ 200000 ], i, j, t;
    __int64 ac = 1;
    for ( i = 0; su[ i ] <= n && i < sucnt; i++ )
    {
        f[ i ] = 0;
        t = n / su[ i ];
        while ( t )
        {
            f[ i ] += t;
            t /= su[ i ];
        }
    }
    for ( i = 0; su[ i ] <= m && i < sucnt; i++ )
    {
        t = m / su[ i ];
        while ( t )
        {
            f[ i ] -= t;
            t /= su[ i ];
        }
    }
    for ( i = 0; su[ i ] <= n - m && i < sucnt; i++ )
    {
        t = ( n - m ) / su[ i ];
        while ( t )
        {
            f[ i ] -= t;
            t /= su[ i ];
        }
    }
    for ( i = 0; su[ i ] <= n && i < sucnt; i++ )
        for ( j = 0; j < f[ i ]; j++ )
            ac = ( ac * su[ i ] ) % 20100501;
    return ac;
}

int main( )
{
    int t, n, m;
    __int64 x, y;
    init( );
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d%d", &n, &m);
        x = C( n + m, n );
        y = C( n + m, n + 1 );
        printf("%I64d\n", ( x - y + 20100501 ) % 20100501);
    }
    return 0;
}
